import socket

HOST = 'localhost'
PORT = 12455
BUFSIZ = 1024

ADDR = (HOST, PORT)


def request():
    s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    s.connect(ADDR)

    while True:
        data = input('>')
        if not data:
            break
        s.send(data.encode('utf-8'))
        d = s.recv(BUFSIZ)
        print('receive data:' + str(d, 'utf-8'))
        if not d:
            break
    s.close()


if __name__ == "__main__":
    request()
